package com.testdemo.web.shapecalc.impl;

import com.testdemo.web.question.IQuestion;
import com.testdemo.web.shapejudge.impl.TriangleJudgeQuestionImpl;

public class QuestionFactory {
	public IQuestion CreateQuestion(int type)
	{
		IQuestion question = null;
		switch(type)
		{
		case 1:
			question = new TriangleQuestionImpl();
			break;
		case 2:
			question = new RectangleQuestionImpl();
			break;
		case 3:
			question = new CircleQuestionImpl();
			break;
		case 4:
			question = new HeartQuestionImpl();
			break;
		case 5:
			question = new  SquareQuestionImpl();
			break;
		case 6:
			question = new TriangleJudgeQuestionImpl();
			break;
		}
		return question;
	}
	
	public IQuestion CreateQuestion(String type)
	{
		IQuestion question = null;
		if (type == "Triangle")
			question = new TriangleQuestionImpl();
		else if (type == "Rectangle")
			question = new RectangleQuestionImpl();
		else if (type == "Circle")
			question = new CircleQuestionImpl();
		else if (type == "Heart")
			question = new HeartQuestionImpl();
		else if (type == "Square")
			question = new  SquareQuestionImpl();
		else if (type == "TriangleJudge")
			question = new TriangleJudgeQuestionImpl();
	 
		return question;
	}
	public int getQuestionTypeId(String type)
	{
		int typeid = 1;
		if (type == "class com.sample.shapecalc.impl.TriangleQuestionImpl")
			typeid = 1;
		else if (type == "class com.sample.shapecalc.impl.RectangleQuestionImpl")
			typeid = 2;
		else if (type == "class com.sample.shapecalc.impl.CircleQuestionImpl")
			typeid = 3;
		else if (type == "class com.sample.shapecalc.impl.HeartQuestionImpl")
			typeid = 4;
		else if (type == "class com.sample.shapecalc.impl.SquareQuestionImpl")
			typeid = 5;
		else if (type == "class com.sample.question.IShapeJudgeQusition.TriangleJudgeQuestionImpl")
			typeid = 6; 
		return typeid;
	}
	
}
